df_week <- df %>%
filter(`Jurisdiction of Occurrence` == "United States") %>%
select(`Week Ending Date`, all_of(disease_order)) %>%
pivot_longer(
cols = all_of(disease_order),
names_to = "Disease",
values_to = "Weekly Death Count"
) %>%
rename(Year = `Week Ending Date`)
mortality <- c(
"All Cause",
"Natural Cause"
)
disease_respiratory <- c(
"Other diseases of respiratory system",
"Influenza and pneumonia",
"Chronic lower respiratory diseases"
)
disease_covid <- c(
"COVID-19 (Multiple Cause of Death)",
"COVID-19 (Underlying Cause of Death)",
"COVID"
)
disease_other1 <- c(
"Septicemia",
"Diabetes mellitus",
"Alzheimer disease",
"Cerebrovascular diseases",
"Nephritis, nephrotic syndrome and nephrosis",
"Unclassified symptoms, signs and abnormal findings"
)
disease_other2 <- c(
"Malignant neoplasms",
"Diseases of heart"
)
p1 <- ggplot(df_week %>% filter(Disease %in% mortality),
aes(Year, Disease, fill = `Weekly Death Count`)) +
geom_tile() +
geom_vline(xintercept = as.Date("2020-01-30"), color = "red", linewidth = 1) +
annotate("text",
x = as.Date("2020-02-28"), y = 2,
label = "COVID-19 Begins",
color = "red",
hjust = 0,
size = 3,
fontface = "bold") +
scale_fill_viridis_c(option = "C",
guide = guide_colorbar(
barwidth = unit(10, "cm"),
barheight = unit(0.3, "cm")
)) +
scale_x_date(
breaks = as.Date(paste0(2014:2023, "-01-01")),
labels = date_format("%Y"),
limits = as.Date(c("2013-12-25", "2024-01-05")),
expand = c(0, 0)
) +
labs(x = "Year",
y = "Disease",
fill = "Weekly Death Count") +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(hjust = 1, angle = 0),
legend.position = "top" )
p2 <- ggplot(df_week %>%
filter(Disease %in% disease_respiratory),
aes(Year, Disease, fill = `Weekly Death Count`)) +
geom_tile() +
geom_vline(xintercept = as.Date("2020-01-01"), color = "red", linewidth = 1) +
annotate("text",
x = as.Date("2020-01-30"), y = 2.8,
label = "COVID-19 Begins",
color = "red",
hjust = 0,
size = 3,
fontface = "bold") +
scale_fill_viridis_c(option = "D",
guide = guide_colorbar(
barwidth = unit(10, "cm"),
barheight = unit(0.3, "cm")
)) +
scale_x_date(
breaks = as.Date(paste0(2014:2023, "-01-01")), # ticks at Jan 1 each year
labels = date_format("%Y"),
limits = as.Date(c("2013-12-25", "2024-01-05")),
expand = c(0, 0)
) +
labs(x = "Year",
y = "Disease",
fill = "Weekly Death Count") +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(hjust = 1, angle = 0),
legend.position = "top" )
p3 <- ggplot(df_week %>% filter(Disease %in% disease_covid),
aes(Year, Disease, fill = `Weekly Death Count`)) +
geom_tile() +
geom_vline(xintercept = as.Date("2020-01-01"), color = "red", linewidth = 1) +
annotate("text",
x = as.Date("2020-02-01"), y = 2.8,
label = "COVID-19 Begins",
color = "red",
hjust = 0,
size = 3,
fontface = "bold") +
scale_fill_viridis_c(option = "A",
na.value = "lightgrey",
guide = guide_colorbar(
barwidth = unit(10, "cm"),
barheight = unit(0.3, "cm")
)) +
scale_x_date(
breaks = as.Date(paste0(2020:2023, "-01-01")), # ticks at Jan 1 each year
labels = date_format("%Y"),
limits = as.Date(c("2013-12-25", "2024-01-05")),
expand = c(0, 0)
) +
labs(x = "Year",
y = "Disease",
fill = "Weekly Death Count") +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(hjust = 1, angle = 0),
legend.position = "top" )
p4 <- ggplot(df_week %>% filter(Disease %in% disease_other1),
aes(Year, Disease, fill = `Weekly Death Count`)) +
geom_tile() +
geom_vline(xintercept = as.Date("2020-01-01"), color = "red", linewidth = 1) +
annotate("text",
x = as.Date("2020-01-30"), y = 5.8,
label = "COVID-19 Begins",
color = "red",
hjust = 0,
size = 3,
fontface = "bold") +
scale_fill_viridis_c(option = "F",
guide = guide_colorbar(
barwidth = unit(10, "cm"),
barheight = unit(0.3, "cm")
)) +
scale_x_date(
breaks = as.Date(paste0(2014:2023, "-01-01")), # ticks at Jan 1 each year
labels = date_format("%Y"),
limits = as.Date(c("2013-12-25", "2024-01-05")),
expand = c(0, 0)
) +
labs(x = "Year",
y = "Disease",
fill = "Weekly Death Count") +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(hjust = 1, angle = 0),
legend.position = "top" )
p5 <- ggplot(df_week %>% filter(Disease %in% disease_other2),
aes(Year, Disease, fill = `Weekly Death Count`)) +
geom_tile() +
geom_vline(xintercept = as.Date("2020-01-01"), color = "red", linewidth = 1) +
annotate("text",
x = as.Date("2020-01-30"), y = 2,
label = "COVID-19 Begins",
color = "red",
hjust = 0,
size = 3,
fontface = "bold") +
scale_fill_viridis_c(option = "E",
guide = guide_colorbar(
barwidth = unit(10, "cm"),
barheight = unit(0.3, "cm")
)) +
scale_x_date(
breaks = as.Date(paste0(2014:2023, "-01-01")),
labels = date_format("%Y"),
limits = as.Date(c("2013-12-25", "2024-01-05")),
expand = c(0, 0)
) +
labs(x = "Year",
y = "Disease",
fill = "Weekly Death Count") +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(hjust = 1, angle = 0),
legend.position = "top" )
plot_grid(p1, p2, p3, p4, p5,
labels = c("A. Mortality of Natural Cause vs. All Cause",
"B. Mortality Attributable to Respiratory Diseases",
"C. Mortality Attributable to COVID-19",
"D. Mortality Attributable to Other Diseases",
"E. Mortality Attributable to Other Diseases cont."),
label_x = 0,
label_y = 1,
hjust = 0,
label_size = 10,
label_fontface = "bold",
ncol = 1,
align = "v",
rel_heights = c(1.3, 1.4, 1.4, 1.8, 1.3))
rm(p1, p2, p3, p4, p5)